//package com.zht.utils;
//
//import coo.exception.BusinessException;
//import org.hibernate.validator.HibernateValidator;
//
//import javax.validation.ConstraintViolation;
//import javax.validation.Validation;
//import javax.validation.Validator;
//import java.util.Set;
//
//public class ValidatorUtils {
//    private static Validator validatorFast = Validation.byProvider(HibernateValidator.class).configure().failFast(true).buildValidatorFactory().getValidator();
//
//    /**
//     * 校验遇到第一个不合法的字段直接返回不合法字段，后续字段不再校验
//     */
//    public static <T> Set<ConstraintViolation<T>> validateFast(T domain) throws Exception {
//        Set<ConstraintViolation<T>> validateResult = validatorFast.validate(domain);
//        if (validateResult.size() > 0) {
//            throw new BusinessException(validateResult.iterator().next().getPropertyPath() + "：" + validateResult.iterator().next().getMessage());
//        }
//        return validateResult;
//    }
//}
